#!/bin/bash  
  
# 检查参数数量  
if [ "$#" -ne 2 ]; then  
    echo "Usage: $0 <start_rule_number> <end_rule_number>"  
    exit 1  
fi  
  
CHAIN=INPUT  
START=$1  
END=$2  
  
# 检查序号是否有效（可选）  
if ! [[ "$START" =~ ^[0-9]+$ ]] || ! [[ "$END" =~ ^[0-9]+$ ]]; then  
    echo "Error: Start and end rule numbers must be integers."  
    exit 1  
fi  
  
if [ "$START" -gt "$END" ]; then  
    echo "Error: Start rule number must be less than or equal to end rule number."  
    exit 1  
fi  
  
# 删除指定序号的规则  
for ((i=$END; i>=$START; i--)); do  
    sudo iptables -D $CHAIN $i  
done